<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateChatRoomMessagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('chat_room_messages', function (Blueprint $table) {
            $table->id();
            $table->integer('chat_room_id')->comment('聊天室ID');
            $table->integer('chat_room_user_id')->comment('发言人ID');
            $table->integer('type')->index()->comment('消息类型:1.文本、2.表情、3.图片、4.商品、5.订单、6.其他');
            $table->text('content')->comment('消息内容');
            $table->text('remarks')->comment('消息备注');
            $table->integer('read_num')->default(0)->comment('读取数量');
            $table->integer('is_push')->default(1)->comment('是否推送:1.已推送 2.未推送');
            $table->timestamps();
            
            $table->index(['chat_room_id', 'chat_room_user_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('chat_room_messages');
    }
}
